<?php
$query = "select * from `radio_dj` where `userid`='$id'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
	$query = "select * from `radio_request`";
	$result = mysql_query($query);
	while ($request = mysql_fetch_array($result)) {
		xmlwriter_start_element($xml,"request");
		xmlwriter_write_element($xml,"id",	$request['id']);
		xmlwriter_write_element($xml,"time",	$request['time']);
		xmlwriter_write_element($xml,"ip",	$request['ip']);
		if ($request['userid']) {
		$query2 = "select `name` from `users` where `id`='".$request['userid']."'";
		$result2 = mysql_query($query2);
		$username = mysql_result($result2,0);
		if ($username) xmlwriter_write_element($xml,"userid",	$request['userid']);
		if ($username) xmlwriter_write_element($xml,"username",	$username);
		}
		xmlwriter_write_element($xml,"from",	$request['from']);
		xmlwriter_write_element($xml,"to",	$request['to']);
		xmlwriter_write_element($xml,"artist",	$request['artist']);
		xmlwriter_write_element($xml,"song",	$request['song']);
		xmlwriter_write_element($xml,"text",	$request['text']);
		xmlwriter_end_element($xml);
	}
} else {
xmlwriter_write_element($xml,"error",	"You are no DJ");
header("403 You cannot access the DJ requests since you are no DJ" );
}

				

?>
